package syntelos.sx;

import alto.lang.Date;
import alto.lang.Message;

/**
 * 
 */
public final class LogSO
    extends syntelos.lang.Message.Queue
{

    protected final Server server;


    public LogSO(Message.Queue queue, Server server){
        super(queue,server.getServerReferenceOpen());
        if (null != server)
            this.server = server;
        else
            throw new IllegalArgumentException();
    }

    public void formatMessage()
        throws java.io.IOException
    {
        this.resetall();
        Server server = this.server;
        String reference = SafeEmpty(this.getReferenceString());
        String secure_ciphers = server.getSecureEnabledCiphersString();
        if (null != secure_ciphers)
            secure_ciphers = " secure-ciphers=\""+secure_ciphers+"\"";
        else
            secure_ciphers = "";
        String secure_protocols = server.getSecureEnabledProtocolsString();
        if (null != secure_protocols)
            secure_protocols = " secure-protocols=\""+secure_protocols+"\"";
        else
            secure_protocols = "";
        //
        this.println("<log type=\"server\" event=\"open\" protocol=\""+server.getProtocol()+"\" port=\""+server.getPort()+"\" name=\""+server.getName()+"\" date=\""+Date.ToString()+"\""+secure_ciphers+secure_protocols+" reference=\""+reference+"\"/>");
    }
}
